import request from '@/utils/request'

export default {
  getUserList(searchModel) {
    return request({
      url: '/user/list',
      method: 'get',
      params: searchModel
    })
  },
  addUser(user) {
    return request({
      url: '/user',
      method: 'post',
      data: user
    })
  },
  deleteUserById(id) {
    return request({
      url: `/user/${id}`,
      method: `delete`
    })
  },
  getUserById(id) {
    return request({
      url: `/user/${id}`,
      method: `get`
    })
  },
  updateUserById(user) {
    return request({
      url: "/user/",
      method: `put`,
      data: user
    })
  },
  saveUser(user) {
    if(user.id == null) {
      return this.addUser(user);
    }else {
      return this.updateUserById(user);
    }
  },
}
